package com.yz.kafka.controller;

import com.yz.kafka.service.KafkaTestComponent;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yuanzheng
 * @since 2021/01/22
 */
@RestController
@RequestMapping("/kafka")
public class KafkaTestController {

    @Resource(name = "kafkaTestComponent")
    private KafkaTestComponent kafkaTestComponent;

    @PostMapping("/producerSynAndCustomSerializer")
    @ApiOperation(value = "同步发送消息并自定义系列化器", tags = {"Kafka生产者"})
    public void producerSynAndCustomSerializer() {
        kafkaTestComponent.producerSynAndCustomSerializer();
    }

    @PostMapping("/producerAsynAndCustomPartition")
    @ApiOperation(value = "异步发送消息并自定义分区", tags = {"Kafka生产者"})
    public void producerAsynAndCustomPartition() {
        kafkaTestComponent.producerAsynAndCustomPartition();
    }

    @PostMapping("/consumerSyn")
    @ApiOperation(value = "同步发送偏移量", tags = {"Kafka消费者"})
    public void consumerSyn() {
        kafkaTestComponent.consumerSyn();
    }

    @PostMapping("/consumerAsyn")
    @ApiOperation(value = "异步发送偏移量", tags = {"Kafka消费者"})
    public void consumerAsyn() {
        kafkaTestComponent.consumerAsyn();
    }


}
